/**
 * tigerrad 
 * fall 2006
 */

#ifndef _SIMULATION_H
#define _SIMULATION_H

#include "Util.h"
#include "Scene.h"
#include "Engine.h"

/**
 * Control input and updating of a Scene.
 */
class Simulation
{
	public:
		/**
		 * Constructor.
		 * @param s the Scene in the Simulation
		 */
		Simulation(ScenePtr s, EnginePtr e) : _scene(s), _engine(e), 
			_finished(false), _leftKeyDown(false), _rightKeyDown(false),
			_fps(false), _animate(false)
		{ }

		/**
		 * Take a simulation step
		 * @param delta Time in ms since last step.
		 */
		void step(unsigned int delta);
		
		/**
		 * Handle key down from SDL.
		 */
		void handleKeyPress(SDL_keysym* keysym);

		/**
		 * Handle key up from SDL.
		 */
		void handleKeyRelease(SDL_keysym* keysym);

		/**
		 * Handle mouse motion from SDL.
		 */
		void handleMouseMotion(SDL_MouseMotionEvent* event);

		/**
		 * Return the Scene used in the Simulation.
		 */
		ScenePtr getScene() const { return _scene; }

		/**
		 * True if the Simulation has finished.
		 */
		bool finished() const { return _finished; }

		/**
		 *  Print help text...
		 */
		void help();

		/**
		 * Record the last fps
		 */
		void recordFPS(float fps) 
		{ 
			if(_fps) 
				std::cout << "FPS: " << fps << std::endl;
		}

		/**
		 * Desctructor
		 */
		virtual ~Simulation()
		{
			// TODO
		}

	private:
		ScenePtr _scene;
		EnginePtr _engine;
		bool _finished;
		bool _leftKeyDown;
		bool _rightKeyDown;
		int _fromLightTex;
		bool _fps;
		bool _animate;

};

typedef boost::shared_ptr<Simulation> SimulationPtr;

#endif

